package com.maila.xiaoaoschool.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import com.android.volley.VolleyError;
import com.google.gson.Gson;
import com.maila.xiaoaoschool.R;
import com.maila.xiaoaoschool.adapter.KefuAdapter;
import com.maila.xiaoaoschool.api.LoginApi;
import com.maila.xiaoaoschool.entity.KefuData;
import com.maila.xiaoaoschool.net.VolleyInterface;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

 /**
  * 客服
 * Created by Administrator on 2017/10/18.
 */

public class ContactActivity extends AppCompatActivity {
    @BindView(R.id.white_return_iv)
    AutoRelativeLayout whiteReturnIv;
    Gson gson = new Gson();
    @BindView(R.id.lv_kefu)
    ListView lvKefu;
    KefuAdapter kefuAdapter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact);
        ButterKnife.bind(this);
        kefuAdapter=new KefuAdapter(this);
        lvKefu.setAdapter(kefuAdapter);
        new LoginApi(this, new VolleyInterface() {
            @Override
            public void onSuccess(String result) {
                KefuData kefuData = gson.fromJson(result, KefuData.class);
                if (kefuData.getResult() == 1) {
                    kefuAdapter.setMdata(kefuData.getData());
                } else {

                }
            }

            @Override
            public void onError(VolleyError error) {

            }
        }).getkefuinfo();
    }

    @OnClick(R.id.white_return_iv)
    public void onViewClicked() {
        finish();
    }
}
